Conventionally, there exists an image processing method called toon shading. To on shading is a method of rendering 3D graphics such that a 3D model composed of a plurality of polygons is shaded so as to obtain a well-defined transition between light and dark, similar to an animation cel (see, for example, Japanese Laid-Open Patent Publication No. 2001-84405).
General toon shading will be described below.
In the step of shading a polygon, first, the brightness of the polygon is determined by lighting. In general shading, by multiplying the brightness by predetermined colors of the polygon and texture, light and dark tones are produced on these colors. In toon shading, on the other hand, after determining the brightness of a polygon, an extra step of calculation is performed.
Specifically, in toon shading, the process of processing brightness is performed such that the brightness is the same in a brightness range from a certain brightness to a certain brightness. After processing a gradual brightness change into a brightness change with some levels (e.g., three levels), light and dark are produced on the colors of the polygon and texture by using the brightness with some levels. In this manner, an image having a well-defined transition between light and dark, which is characteristic of an animation cel, is obtained.
The above-described conventional toon shading, however, requires special settings to render individual 3D models, whereby the amount of data is increased or the image processing program becomes complex, causing an increase in processing time.
Moreover, in the conventional toon shading, a process is performed on a polygon-by-polygon basis. Therefore, with an increase in the number of polygons to be rendered, an increase in processing load is caused.
Certain exemplary illustrative embodiments have the following features. It is to be understood that reference numerals, etc., in parentheses are provided, for the purpose of assisting in the understanding of the exemplary illustrative embodiments, as will be described later, and thus are not intended to limit the scope of the present invention.
A first aspect of certain exemplary embodiments is directed to an image processing program for causing a computer to generate an image to be viewed from a virtual camera in a 3D virtual space by rendering in a rendering region (210) a 3D model arranged in the 3D virtual space. The image processing program allows the computer to function as rendering means (S11 to S14), brightness derivation means (S22), gray level number reduction means (S23, S24), and color value changing means (S25). Specifically, in the image processing program of certain exemplary illustrative embodiments, the computer acts as the rendering means to render the 3D model in the rendering region to generate an image to be viewed from the virtual camera, acts as the brightness derivation means to derive a brightness value from color values of each pixel of the image which has been rendered in the rendering region, acts as the gray level number reduction means to reduce the number of gray levels of the brightness values derived by the brightness derivation means to convert the brightness values into brightness values for toon processing, and acts as the color value changing means to change all the color values of each pixel of the image in the rendering region based on the brightness value for toon processing.
The color values may be RGB values defined by three primary colors of light, a red value (R), a green value (G), and a blue value (B); as the brightness derivation means, the computer may convert the RGB values of each pixel in the rendering region into YUV values defined by a brightness value (Y), a bluish value (U), and a reddish value (V), thereby deriving a brightness value for each pixel; and as the color value changing means, the computer may multiply all the RGB values of each pixel in the rendering region by the brightness value for toon processing on a pixel-by-pixel basis.
As the gray level number reduction means, the computer may perform a scale-down step (S23) of scaling down the brightness values derived by the brightness derivation means and a scale-up step (S24) of scaling up the scaled-down values.
In the case where a plurality of 3D models are arranged in the virtual space, as the rendering means, the computer may render only a specific 3D model to generate unprocessed image data (S141) and then render, after the specific 3D model has been processed by the color value changing means, the rest of the 3D models (S142).
In the case where a plurality of 3D models are arranged in the virtual space, when the computer acts as the rendering means to render the 3D models to generate unprocessed image data, the computer may store flags of pixels corresponding to a specific 3D model (S143); and the computer may perform processes of the brightness derivation means, the gray level number reduction means, and the color value changing means only on the pixels corresponding to the specific 3D model by referring to the flags.
A second aspect of certain exemplary illustrative embodiments is directed to an image processing apparatus comprising a computer which has the above-described image processing program stored therein and functions by using the program.
According to certain exemplary illustrative embodiments, toon processing is performed on image data which is obtained by rendering a 3D model. Therefore, no special settings are required to render individual 3D models, and in addition, an increase in processing time due to an increase in the amount of data or a complex image processing program is not caused. Further, an infinite increase in processing load for toon processing along with an increase in the number of polygons to be rendered is not caused.
In particular, in the case where the RGB values of unprocessed image data are converted based on a brightness for toon processing by multiplying the RGB values of the unprocessed image data by the brightness for toon processing on a pixel-by-pixel basis, the image data can be converted in an animated form at without losing the gray levels of the image before being processed. Accordingly, an additional effect of being able to obtain an image which is in an animated format but maintains a somewhat realistic tone, can be obtained.
By producing brightness for toon processing by first scaling down brightness values derived by the brightness derivation means and then scaling up the scaled-down brightness values, an additional effect of being able to simplify the process of reducing the number of gray levels of the brightness can be obtained.
By performing toon processing on image data generated by rendering a specific 3D model and then rendering the rest of the 3D models, an additional effect of being able to perform toon processing only on the specific 3D model can be obtained. In addition, the same effect can be obtained by storing flags of pixels corresponding to a specific 3D model upon rendering 3D models, and performing a brightness derivation process and an image data conversion process only on the pixels corresponding to the specific 3D model based on the flags.